//
// Created by 吴锐 on 2022/3/1.
//

#include <vector>
#include "iostream"
#include "string"
#include "deque"
#include "algorithm"

using namespace std;

class Person {
public:
    string m_Name;
    int m_Score;

    Person(string name, int score){
        this->m_Name = name;
        this->m_Score = score;
    }
};

void createPerson(vector<Person>& v) {
    string nameSeed = "ABCDE";
    for(int i = 0 ; i < 5 ; i++){
        string name = "选手";
        name += nameSeed[i];
        int score = 0;
        Person p(name, score);
        v.push_back(p);
    }
}

void setScore(vector<Person>& v){
    for(vector<Person>::iterator it = v.begin() ; it != v.end() ; it++){
        deque<int> d;
        for(int i = 0 ; i < 10 ; i++){
            int score = rand() & 41 + 60;
            d.push_back(score);
        }

        for(deque<int>::iterator dit = d.begin() ; dit != d.end() ; it++){
            cout << *dit << " ";
        }
        cout << endl;

        sort(d.begin(), d.end());

        d.pop_back();
        d.pop_front();

        int sum = 0;
        for(deque<int>::iterator dit = d.begin() ; dit != d.end() ; dit++){
            sum += *dit;
        }

        int avg = sum / d.size();
        it->m_Score = avg;
    }
}

int main(){
    vector<Person> v;
    createPerson(v);
    for(vector<Person>::iterator it = v.begin() ; it != v.end() ; it++){
        cout << "姓名: " << (*it).m_Name << " 分数: " << (*it).m_Score << endl;
    }
    setScore(v);
    return 0;
}